﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace BLL
{
    public class ReviewManager
    {
        public static DataSet GetAllReviews(int parentId, string cultureName, int startRowIndex, int maximumRows)
        {
            using (DataSet ds = BLL.BLLManager.ExecGetDSAllSP("ReviewsByPage", new object[] { parentId, cultureName, startRowIndex, maximumRows }))
            {
                ds.DataSetName = "Reviews";
                ds.Tables[0].TableName = "Category";
                ds.Tables[1].TableName = "Review";
                ds.Tables[2].TableName = "RowInfo";
                DataRelation relation = new DataRelation("ParentChild", ds.Tables["Category"].Columns["CategoryID"], ds.Tables["Review"].Columns["CategoryID"]);
                ds.Relations.Add(relation);
                return ds;
            }
        }
        public static int RemoveReview(int ID)
        {
            return BLL.BLLManager.ExceDeleteSP("Review", new object[] { ID });
        }

        public static int AddReview(int categoryID, string userName, string language, string title, string review, int rate)
        {

            return BLL.BLLManager.ExceInsertToSP("Review",
                new object[]
                { 
                  categoryID, userName, language,title, review,rate,DateTime.Now
                }
                );
        }
        public static IDataReader GetRandomReview(string language)
        {
            return BLL.BLLManager.ExecGetDRRandomSP("Review", new object[] { language });
        }

    }
}
